import { post, get } from "./../utils/http";
import URL from "./../utils/url";
import { Toast } from "vant";
import router from "../router";
export default {
  Get_userData({ commit }) {
    post(`${URL.member.url}`, {}).then((res) => {
      if (res.code == 0) {
        commit("SET_H5URL", res.data);
      } else {
        //Toast(res.message);
      }
    });
    return new Promise((resolve, reject) => {
      post(`${URL.member.personal}`, {}).then((res) => {
        if (res.code == 0) {
          commit("SET_USERDATA", res.data);
          resolve(res);
        } else {
          Toast(res.message);
          reject(res);
        }
      });
    });
  },
  getH5Url({ commit }) {
    post(`${URL.member.url}`, {}).then((res) => {
      if (res.code == 0) {
        commit("SET_H5URL", res.data);
      }
    });
  },
  resetVuex({ commit }) {
    commit("SET_USERDATA", {});
    commit("SET_TOKEN", "");
    commit("SET_LOGIN", false);
    localStorage.removeItem("gender");
    localStorage.removeItem("identityNumber");
    localStorage.removeItem("type");
    localStorage.removeItem("countryName");
    localStorage.removeItem("name");
    localStorage.removeItem("hz");
    localStorage.removeItem("sfz2");
    localStorage.removeItem("sfz1");
    localStorage.removeItem('closemodal')
  },

  changeState({ state }, { attr, params }) {
    state[attr] = params;
  },

  UpadteHtml5Tags({ commit }) {
    post(URL.common.h5page_list, {}).then((res) => {
      if (res.code == 0) {
        commit("SET_HTML5TAGS", res.data);
      } else {
        Toast(res.message);
      }
    });
  },
  SetWelfareEyes_2({ commit }, bShow) {
    commit("SET_WELFAREEYES_2", bShow);
  },
};
